<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>One To One - Join Table</title>
</head>
<body>
<pre class="brush: java">
//Package declaration and imports omitted for brevity
//Desk.java source  
@Entity(name = "OtoJoinTableDesk")
@Table(name = "oto_join_desk")
public class Desk {
	private int id;
	private String number;
	
	public Desk() {}

	public Desk(String number) {
		this.number = number;
	}

	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}

	private void setId(int id) {
		this.id = id;
	}

	@Column(nullable = false, length = 30)
	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}	
}

///////////////////////////////////////////////

//Employee.java
@Entity(name="OtoJoinTableEmployee") 
@Table(name = "oto_join_employee")
public class Employee {
	
	private int id;
	private String name;
	private Desk desk;
	
	public Employee() {}

	public Employee(String name) {
		this.name = name;
	}

	@Id @GeneratedValue
	public int getId() {
		return id;
	}
	
	private void setId(int id) {
		this.id = id;
	}
	
	@Column(nullable = false, length = 30)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	@OneToOne
	@JoinTable(
		name="oto_join_emp_desk",
		joinColumns = @JoinColumn(name = "emp_id"),
		inverseJoinColumns = @JoinColumn(name = "desk_id",
      unique = true)
	)	
	public Desk getDesk() {
		return desk;
	}

	public void setDesk(Desk desk) {
		this.desk = desk;
	}
}
</pre>
</body>
</html>
